<template>
	<jk-dialog
		v-model="showDialog"
		title="详情-回花品种"
		width="1000px"
		:show-content-loading="showLoading"
		append-to-body
		:show-cancel-btn="false"
		:show-close-btn="true"
		:show-confirm-btn="false"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form
			ref="ruleForm"
			:model="ruleForm"
			label-width="110px"
			:show-message="false"
		>
			<el-row ref="box1">
				<el-col :span="22">
					<el-form-item class="margin-bottom-10" label="物料">
						<span class="read-only-2">{{ ruleForm.typeName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="22">
					<el-form-item class="margin-bottom-10" label="规格">
						<span class="read-only-2">{{ ruleForm.name }}</span>
					</el-form-item>
				</el-col>
				<!--				<el-col :span="20">-->
				<!--					<el-form-item class="margin-bottom-10" label="状态">-->
				<!--						<div class="read-only-2">-->
				<!--							<jk-common-status :status="ruleForm.auditState"></jk-common-status>-->
				<!--						</div>-->
				<!--					</el-form-item>-->
				<!--				</el-col>-->
			</el-row>
		</el-form>
		<jk-table border :data="ruleForm.standardList || []">
			<vxe-column title="序号" type="seq" align="center" :width="60"></vxe-column>
			<vxe-column title="最小标准百分比" align="left" field="minStandard" :min-width="120">
				<template slot-scope="scope">
					<jk-input v-model="scope.row.minStandard" disabled placeholder="最小标准百分比" size="mini"></jk-input>
				</template>
			</vxe-column>
			<vxe-column title="最大标准百分比" align="left" field="maxStandard" :min-width="120">
				<template slot-scope="scope">
					<jk-input v-model="scope.row.maxStandard" disabled placeholder="最大标准百分比" size="mini"></jk-input>
				</template>
			</vxe-column>
			<vxe-column title="选择月份" align="center" field="yearMonth" :min-width="360">
				<template slot-scope="scope">
					<div class="flex-start-center">
						<el-date-picker
							v-model="scope.row.startYearMonth"
							size="mini"
							type="month"
							disabled
							format="yyyy-MM"
							value-format="yyyy-MM"
							placeholder="选择开始月份"
						>
						</el-date-picker>
						<span style="margin: 0 6px">-</span>
						<el-date-picker
							v-model="scope.row.endYearMonth"
							size="mini"
							disabled
							type="month"
							format="yyyy-MM"
							value-format="yyyy-MM"
							placeholder="选择结束月份"
						>
						</el-date-picker>
					</div>
				</template>
			</vxe-column>
		</jk-table>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-table-height';
    import { spinMaterialGet } from '@/api/material/rawMaterial';
    export default {
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataId: {
                type: [String, Number],
                default: ''
            }
        },
        mixins: [calHeight],
        data() {
            return {
                showDialog: false,
                showLoading: true,
                ruleForm: {}
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                }
            },
            getDetailRequest() {
                this.showLoading = true;
                return spinMaterialGet({ id: this.dataId }).then((res) => {
                    this.showLoading = false;
                    if (res.data.status === 200) {
                        this.ruleForm = res.data.res;
                    }
                });
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
                if (newVal && this.dataId) {
                    this.getDetailRequest();
                }
            }
        }
    };
</script>
